home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Systemmonitors / Snoopy / snoopydebug.s < prev    next >
Text File  |  1996-09-26  |  2KB  |  72 lines

  1. ;--------------    this is it, the debug calling mechanism. don't modify or else...
  2. ;--------------    This function does NOT modify a6 to the outside, but for the
  3. ;--------------    called function. This means, a6 remains the same in the main
  4. ;--------------    programm, but the debugged subroutine will have scratched a6
  5. ;--------------    contents. Sorry folks, but thats about it!
  6. SnoopyDebug:    move.l    a6,-(sp)            ; push old a6
  7.         bsr.s    sd_PrepareMsg            ; setup message
  8.         move.l    a6,-(sp)            ; push message
  9.         move.l    16(sp),sumsg_Template(a6)    ; set template
  10.         move.l    12(sp),a6            ; load function addr
  11.         jsr    (a6)                ; call function
  12.         move.l    (sp)+,a6            ; get message
  13.         bsr    sd_SendMsg            ; send message
  14.         move.l    (sp)+,a6            ; get old a6
  15.         move.l    (sp),8(sp)            ; set return addr
  16.         addq.l    #8,sp                ; skip stack
  17.         rts                    ; done
  18.  
  19. ;--------------    this is used to prepare the message; i.e. allocate the
  20. ;--------------    needed memory and save the "registers-before-call"
  21. sd_PrepareMsg:    movem.l    d0-d7/a0-a5,-(sp)
  22.         movea.l    4.w,a6
  23.         move.l    #sumsg_SIZEOF,d0
  24.         move.l    #$10001,d1    ; MEMF_PUBLIC|MEMF_CLEAR
  25.         jsr    -198(a6)    ; AllocMem()
  26.         movea.l    d0,a0
  27.         move.l    276(a6),sumsg_Task(a0)    ; ExecBase->ThisTask
  28.         movea.l    d0,a6
  29.         movem.l    (sp)+,d0-d7/a0-a5
  30.         cmpa.l    #0,a6
  31.         beq    sdpm_Failed
  32.         SAVEREGS sumsg_RegsBeforeCall
  33.         nop
  34. sdpm_Failed:    rts
  35.  
  36. ;--------------    this procedure sends the message to snoopy. It is called
  37. ;--------------    after the user function has been executed, so that the
  38. ;--------------    "registers-after-call" field can be setup
  39. sd_SendMsg:    cmpa.l    #0,a6
  40.         beq    sdsm_Failed
  41.         SAVEREGS sumsg_RegsAfterCall
  42.         movem.l    d0-d7/a0-a5,-(sp)
  43.         movea.l    a6,a5            ; a5 = message
  44.         movea.l    4.w,a6            ; a6 = ExecBase
  45.  
  46. ;--------------    find the message port to send our messages to
  47.         lea    SnoopyPortName(pc),a1    ; name
  48.         jsr    -390(a6)        ; FindPort()
  49.         tst.l    d0
  50.         beq.s    sdsm_NoPort
  51.         movea.l    d0,a4            ; a4 = port
  52.  
  53. ;--------------    prepare message
  54.         move.b    #5,8(a5)         ; #NT_MESSAGE,LN_TYPE(a5)
  55.         move.w    #sumsg_SIZEOF,18(a5)     ; MN_LENGTH(a5)
  56.         move.w    #MSGTYPEF_DEBUG,sumsg_Type(a5)
  57.         move.l    #0,14(a5)        ; MN_REPLYPORT(a5)
  58.  
  59. ;--------------    send it
  60.         movea.l    a4,a0            ; port
  61.         movea.l    a5,a1            ; message
  62.         jsr    -366(a6)        ; PutMsg()
  63.         bra.s    sdsm_Done
  64.  
  65. ;--------------    port not found -> deallocate memory
  66. sdsm_NoPort:    movea.l    a5,a1
  67.         move.l    #sumsg_SIZEOF,d0
  68.         jsr    -210(a6)        ; FreeMem()    
  69. sdsm_Done:    movem.l    (sp)+,d0-d7/a0-a5
  70. sdsm_Failed:    rts
  71.  
  72.